package de.matusystems.rest

class ImageTransformationWebService {

	public byte[] createThumbnail(String imageUrl, int width, int height) {

		URL url = new URL(System.getenv()['CAPP_IMAGE_SERVICE']+"?url="+imageUrl+"&action=resize&width="+width+"&height="+height);
		URLConnection urlc = url.openConnection();

		BufferedInputStream bis = new BufferedInputStream(urlc.getInputStream());
		ByteArrayOutputStream baos = new ByteArrayOutputStream();

		int i;
		while ((i = bis.read()) != -1) {
			baos.write(i);
		}

		return baos.toByteArray();
	}
}
